/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserInfo.java
 *
 * Created on 2012-6-9, 10:51:49
 */

package icexam.user;

import icexam.ICExamView;
import icexam.exam.print.ReportViewAction;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Ethan
 */
public class UserInfo extends javax.swing.JPanel {

    /** Creates new form UserInfo */
    public UserInfo() {
        initComponents();
    }

    private ICExamView mainView;
    UserInfo(ICExamView mainView) {
        this();
        this.mainView = mainView;

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        compNT = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        ceoNT = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        iDT = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jLabel7 = new javax.swing.JLabel();
        studyT = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        bestST = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        jLabel10 = new javax.swing.JLabel();
        bestST1 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();

        setName("Form"); // NOI18N
        setPreferredSize(new java.awt.Dimension(700, 400));

        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(500, 70));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 500, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 70, Short.MAX_VALUE)
        );

        add(jPanel1);

        jPanel2.setName("jPanel2"); // NOI18N
        jPanel2.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(icexam.ICExamApp.class).getContext().getResourceMap(UserInfo.class);
        jLabel1.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N
        jLabel1.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel2.add(jLabel1);

        compNT.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        compNT.setForeground(resourceMap.getColor("compNT.foreground")); // NOI18N
        compNT.setText(resourceMap.getString("compNT.text")); // NOI18N
        compNT.setName("compNT"); // NOI18N
        compNT.setPreferredSize(new java.awt.Dimension(200, 25));
        jPanel2.add(compNT);

        add(jPanel2);

        jPanel3.setName("jPanel3"); // NOI18N
        jPanel3.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel3.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N
        jLabel3.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel3.add(jLabel3);

        ceoNT.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        ceoNT.setForeground(resourceMap.getColor("compNT.foreground")); // NOI18N
        ceoNT.setText(resourceMap.getString("ceoNT.text")); // NOI18N
        ceoNT.setName("ceoNT"); // NOI18N
        ceoNT.setPreferredSize(new java.awt.Dimension(200, 25));
        jPanel3.add(ceoNT);

        add(jPanel3);

        jPanel4.setName("jPanel4"); // NOI18N
        jPanel4.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel5.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N
        jLabel5.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel4.add(jLabel5);

        iDT.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        iDT.setForeground(resourceMap.getColor("compNT.foreground")); // NOI18N
        iDT.setText(resourceMap.getString("iDT.text")); // NOI18N
        iDT.setName("iDT"); // NOI18N
        iDT.setPreferredSize(new java.awt.Dimension(200, 25));
        jPanel4.add(iDT);

        add(jPanel4);

        jPanel5.setName("jPanel5"); // NOI18N
        jPanel5.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel5.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel7.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N
        jLabel7.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel5.add(jLabel7);

        studyT.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        studyT.setForeground(resourceMap.getColor("compNT.foreground")); // NOI18N
        studyT.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        studyT.setText(resourceMap.getString("studyT.text")); // NOI18N
        studyT.setName("studyT"); // NOI18N
        studyT.setPreferredSize(new java.awt.Dimension(35, 25));
        jPanel5.add(studyT);

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N
        jLabel2.setPreferredSize(new java.awt.Dimension(155, 15));
        jPanel5.add(jLabel2);

        add(jPanel5);

        jPanel6.setName("jPanel6"); // NOI18N
        jPanel6.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel9.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N
        jLabel9.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel6.add(jLabel9);

        bestST.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        bestST.setForeground(resourceMap.getColor("compNT.foreground")); // NOI18N
        bestST.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        bestST.setText(resourceMap.getString("bestST.text")); // NOI18N
        bestST.setName("bestST"); // NOI18N
        bestST.setPreferredSize(new java.awt.Dimension(35, 25));
        jPanel6.add(bestST);

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N
        jLabel4.setPreferredSize(new java.awt.Dimension(155, 15));
        jPanel6.add(jLabel4);

        add(jPanel6);

        jPanel7.setName("jPanel7"); // NOI18N
        jPanel7.setPreferredSize(new java.awt.Dimension(500, 35));
        jPanel7.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.CENTER, 10, 5));

        jLabel10.setFont(resourceMap.getFont("jLabel10.font")); // NOI18N
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N
        jLabel10.setPreferredSize(new java.awt.Dimension(120, 15));
        jPanel7.add(jLabel10);

        bestST1.setFont(resourceMap.getFont("bestST1.font")); // NOI18N
        bestST1.setForeground(resourceMap.getColor("bestST1.foreground")); // NOI18N
        bestST1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        bestST1.setName("bestST1"); // NOI18N
        bestST1.setPreferredSize(new java.awt.Dimension(35, 25));
        jPanel7.add(bestST1);

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.setPreferredSize(new java.awt.Dimension(60, 23));
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel7.add(jButton1);

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N
        jLabel6.setPreferredSize(new java.awt.Dimension(90, 15));
        jPanel7.add(jLabel6);

        add(jPanel7);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        try {
            String[][] titles = new String[3][3];
            titles[0][0] = "合 格 证 书";
             SimpleDateFormat df = new SimpleDateFormat("yyyy年MM月dd日");//设置日期格式
            titles[0][1] = "容县工商行政管理局 "
                    + df.format(new Date());
            String[][] objs = new String[1][3];
            objs[0][0] = "      "+this.mainView.getUser().getCeoName()
                    + " 参加我局举办的容县流通环节食品经营知识培训，并通过了测试，特发此证。";
            ReportViewAction.action(titles, objs,3);

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }//GEN-LAST:event_jButton1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel bestST;
    private javax.swing.JLabel bestST1;
    private javax.swing.JLabel ceoNT;
    private javax.swing.JLabel compNT;
    private javax.swing.JLabel iDT;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JLabel studyT;
    // End of variables declaration//GEN-END:variables

    public void setUser(UserBean user) {
        compNT.setText(user.getCompName());
        ceoNT.setText(user.getCeoName());
        iDT.setText(user.getIdcard());
        studyT.setText(String.valueOf(user.getSpentTime()));
        bestST.setText(String.valueOf(user.getBestScore()));
        if(user.getBestScore()>=90){
            jPanel7.setVisible(true);
        }else
            jPanel7.setVisible(false);
    }

}
